package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.domain.db.Question;
import com.tanhua.dubbo.mapper.QuestionMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.yaml.snakeyaml.events.Event;

@Service
public class QuestionApiImpl implements QuestionApi {

    @Autowired
    private QuestionMapper questionMapper;

    //根据用户id查询陌生人问题
    @Override
    public Question findByUserId(Long id) {
        QueryWrapper<Question> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id", id);

        return questionMapper.selectOne(queryWrapper);
    }

    //更新question
    @Override
    public void update(Question question) {
        questionMapper.updateById(question);
    }

    //添加  创建question对象
    @Override
    public void save(Question question) {
        questionMapper.insert(question);
    }
}
